#include "GAF_Media.h"
#include "GAF_Application.h"

namespace GAF
{
	GAF::MediaTransfer Media::GetMediaTransfer()
	{
		MediaTransfer _mt;
		_mt.doing = MEDIA_QUERYING;
		_mt.file = "";
		_mt.loop = false;
		_mt.channel = 0;
		_mt.volume = 100;
		_mt.jump = 0;

		_mt.state = PLAYER_STOP;
		_mt.timetotal = 0;
		_mt.timecurrent = 0;

		return _mt;
	}

	bool Media::DefaultAudioPlayer( _IN_OUT GAF_SMediaTransfer& mi )
	{
		if(GAF_pTHEPLATFORM == NULL)
			return false;

		return GAF_pTHEPLATFORM->AudioPlayer(mi);
	}

	Media::Media()
	{
		m_mpfUsing = NULL;
	}

	Media::~Media()
	{
		m_mpfUsing = NULL;
	}

	bool Media::Init( STD_STRING strMediaFile, MediaPlayerFun mpfUsing)
	{
		GAF_CHECK_R(mpfUsing != NULL, false);

		m_mpfUsing = mpfUsing;

		if(!OnInit(strMediaFile))
		{
			GAF_ERRMARK();
			m_mpfUsing = NULL;
			return false;
		}

		return true;
	}

	bool Media::MediaPlayer( _IN_OUT GAF_SMediaTransfer& mi )
	{
		GAF_CHECK_R(m_mpfUsing != NULL, false);

		return m_mpfUsing(mi);
	}


}
